package qimao.com.edu.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.fasterxml.jackson.databind.ObjectMapper;

import qimao.com.edu.entity.Author;
import qimao.com.edu.entity.CommenResult;

@WebServlet("/checkSession")
public class SessionCheckServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("application/json;charset=utf-8");
        response.setCharacterEncoding("UTF-8");
        HttpSession session = request.getSession();
        PrintWriter out = response.getWriter();
        ObjectMapper om=new ObjectMapper();
        if (session != null && session.getAttribute("loginUser") != null) {
            String username = "已登录用户";
            out.print("{\"loggedIn\": true, \"username\": \"" + username + "\"}");
        } else {
        }
        out.flush();

    }
}